// 平台属性管理的接口请求函数
import request from "@/utils/request"
// 一级分类 /admin/product/getCategory1 get
export const reqCategory1List = () => {
  return request({
    url: `/admin/product/getCategory1`,
    method: "get",
  })
}

// 二级分类 /admin/product/getCategory2/{category1Id} get
export const reqCategory2List = (category1Id) => {
  return request({
    url: `/admin/product/getCategory2/${category1Id}`,
    method: "get",
  })
}
// 三级分类 /admin/product/getCategory3/{category2Id} get
export const reqCategory3List = (category2Id) => {
  return request({
    url: `/admin/product/getCategory3/${category2Id}`,
    method: "get",
  })
}

// 根据三级分类id获取平台属性列表 /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id} get
export const reqAttrInfoList = (category1Id, category2Id, category3Id) => {
  return request({
    url: `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,
    method: "get",
  })
}
// 添加属性与属性值的接口 /admin/product/saveAttrInfo post
/* {
  "attrName": "", 属性名
  "attrValueList": [  属性名称中属性值，因为属性值可以是多个，因此需要的是数组
    {
      "attrId": 0, 属性的id
      "valueName": "string" 属性值
    }
  ],
  "categoryId": 0, category3Id
  "categoryLevel": 0, 区分几级id
} */
export const reqAddOrUpdateAttr = (data) => {
  return request({
    url: `/admin/product/saveAttrInfo`,
    method: "post",
    data,
  })
}
// 删除三级列表属性名称 /admin/product/deleteAttr/{attrId} delete
export const reqDeleteAttr = (attrId) => {
  return request({
    url: `/admin/product/deleteAttr/${attrId}`,
    method: "delete",
  })
}
